package com.qmyx.supply.admin.controller;

import com.ytjj.qmyx.supplychain.common.api.CommonResult;
import com.ytjj.qmyx.supplychain.mapper.entity.YxBankerSite;
import com.ytjj.qmyx.supplychain.service.BankerSiteService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 
 * 
 * @Version: 1.0
 */
@RestController
@RequestMapping("/bankerSite")
public class BankerSiteController {

    @Resource
    private BankerSiteService bankerSiteService;

    @PostMapping("/site")
    public CommonResult getSite() {
        return CommonResult.success(bankerSiteService.getSite());
    }

    @PostMapping("/syncSite")
    public CommonResult syncSite(@RequestBody YxBankerSite bankerSite){
        Integer count = bankerSiteService.syncSite(bankerSite);
        if (count > 0) {
            return CommonResult.success(count);
        } else {
            return CommonResult.failed();
        }
    }

    @GetMapping("/delete")
    public CommonResult deleteSite(@RequestParam Integer id){
        Integer count = bankerSiteService.deleteSite(id);
        if (count > 0) {
            return CommonResult.success(count);
        } else {
            return CommonResult.failed();
        }
    }
}
